package com.muqi.app.qlearn.adapter;

import java.util.List;

import com.muqi.app.qlearn.student.R;
import com.muqi.app.user.db.CmdLoaclMessage;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class MessageAdapter extends BaseAdapter{
	private Context context;
	private List<CmdLoaclMessage> listData;


	public MessageAdapter(Context context, List<CmdLoaclMessage> listData) {
		this.context = context;
		this.listData = listData;
		
	}

	@Override
	public int getCount() {
		return listData == null ? 0 : listData.size();
	}

	@Override
	public CmdLoaclMessage getItem(int position) {
		return listData.get(position);
	}
   
	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		final CmdLoaclMessage item = listData.get(position);
		if (convertView == null) {
			holder = new ViewHolder();
			convertView = LayoutInflater.from(context).inflate(R.layout.item_message, null);
			holder.type = (TextView) convertView.findViewById(R.id.money_type);
			holder.money = (TextView) convertView.findViewById(R.id.price);
			holder.time = (TextView) convertView.findViewById(R.id.time);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		holder.type.setText(item.titile);
		holder.time.setText(item.time);
		holder.money.setText(item.content);
	
	      
		return convertView;
	}

	private class ViewHolder {
		TextView type;
		TextView money;
		TextView time;
	}
}
